
function pageHelp(options) {
    console.log(777)
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper"></div>')




        if (options.prev) {
            $('.pageHelper').append('<a href="javascript:;" class="prev">上一页</a>');
        }
        $('.pageHelper').append('<div class="thisPage" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage').children().eq(0).addClass('pagehelpAvtive');
        if (options.next) {
            $('.pageHelper').append('<a  href="javascript:;" class="next">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum"/> 页</span>');
            $('.pageHelper').append('<a  href="javascript:;" class="jumpPage" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum').bind('keyup', function (event) {
            if (event.keyCode == "13") {
                //回车执行查询
                handJump();
            }
        });
        $(document).on('click', '.jumpPage', handJump);
        // 首页 
        $(document).on('click', '.firstPage', function () {
            var allIndex = Number($('.pagehelpAvtive').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage(0);
        });
        // 尾页
        $(document).on('click', '.lastPage', function () {
            var allIndex = Number($('.pagehelpAvtive').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage(4);
        });
        // 上一页
        $(document).on('click', '.prev', function () {
            var allIndex = Number($('.pagehelpAvtive').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive').index();
            jumpPage(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next', function () {
            var allIndex = Number($('.pagehelpAvtive').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive').index();
            jumpPage(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage>a', function () {
            var thisIndex = $(this).index();
            jumpPage(thisIndex)
        });
        // 跳转页面
        function jumpPage(thisIndex) {
            if ($('.thisPage>a').eq(thisIndex).hasClass('pagehelpAvtive')) return;
            // if ( allIndex ===  allPage[allPage.length-1]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage>a').removeClass('pagehelpAvtive');
            $('.thisPage>a').eq(thisIndex).addClass('pagehelpAvtive');
            var allIndex = Number($('.pagehelpAvtive').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage').children().eq($('.thisPage').children().length - 1).remove();
                $('.thisPage a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage').children().eq(0).remove();
                $('.thisPage').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump() {
            var jumpNum = Number($('.jumpPageNum').val());
            var allIndex = Number($('.pagehelpAvtive').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage(j);
                }
            }
        }
    })
}


// 第二个分页
function pageHelp1(options) {
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper1"></div>')




        if (options.prev) {
            $('.pageHelper1').append('<a href="javascript:;" class="prev1">上一页</a>');
        }
        $('.pageHelper1').append('<div class="thisPage1" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage1').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage1').children().eq(0).addClass('pagehelpAvtive1');
        if (options.next) {
            $('.pageHelper1').append('<a  href="javascript:;" class="next1">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper1').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper1').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum1"/> 页</span>');
            $('.pageHelper1').append('<a  href="javascript:;" class="jumpPage1" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum1').bind('keyup', function (event) {
            if (event.keyCode == "13") {
                //回车执行查询
                handJump1();
            }
        });
        $(document).on('click', '.jumpPage1', handJump1);
        // 首页 
        $(document).on('click', '.firstPage1', function () {
            var allIndex = Number($('.pagehelpAvtive1').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage1').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage1').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage1(0);
        });
        // 尾页
        $(document).on('click', '.lastPage1', function () {
            var allIndex = Number($('.pagehelpAvtive1').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage1').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage1').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage1(4);
        });
        // 上一页
        $(document).on('click', '.prev1', function () {
            var allIndex = Number($('.pagehelpAvtive1').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive1').index();
            jumpPage1(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next1', function () {
            var allIndex = Number($('.pagehelpAvtive1').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive1').index();
            jumpPage1(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage1>a', function () {
            var thisIndex = $(this).index();
            jumpPage1(thisIndex)
        });
        // 跳转页面
        function jumpPage1(thisIndex) {
            if ($('.thisPage1>a').eq(thisIndex).hasClass('pagehelpAvtive1')) return;
            // if ( allIndex ===  allPage[allPage.length-1]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage1>a').removeClass('pagehelpAvtive1');
            $('.thisPage1>a').eq(thisIndex).addClass('pagehelpAvtive1');
            var allIndex = Number($('.pagehelpAvtive1').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage1').children().eq($('.thisPage1').children().length - 1).remove();
                $('.thisPage1 a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage1').children().eq(0).remove();
                $('.thisPage1').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump1() {
            var jumpNum = Number($('.jumpPageNum1').val());
            var allIndex = Number($('.pagehelpAvtive1').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage1').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage1').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage1(j);
                }
            }
        }
    })
}

// 第三个分页
function pageHelp2(options) {
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper2"></div>')




        if (options.prev) {
            $('.pageHelper2').append('<a href="javascript:;" class="prev2">上一页</a>');
        }
        $('.pageHelper2').append('<div class="thisPage2" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage2').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage2').children().eq(0).addClass('pagehelpAvtive2');
        if (options.next) {
            $('.pageHelper2').append('<a  href="javascript:;" class="next2">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper2').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper2').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum2"/> 页</span>');
            $('.pageHelper2').append('<a  href="javascript:;" class="jumpPage2" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum2').bind('keyup', function (event) {
            if (event.keyCode == "13") {
                //回车执行查询
                handJump2();
            }
        });
        $(document).on('click', '.jumpPage2', handJump2);
        // 首页 
        $(document).on('click', '.firstPage2', function () {
            var allIndex = Number($('.pagehelpAvtive2').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage2').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage2').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage2(0);
        });
        // 尾页
        $(document).on('click', '.lastPage2', function () {
            var allIndex = Number($('.pagehelpAvtive2').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage2').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage2').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage2(4);
        });
        // 上一页
        $(document).on('click', '.prev2', function () {
            var allIndex = Number($('.pagehelpAvtive2').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive2').index();
            jumpPage2(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next2', function () {
            var allIndex = Number($('.pagehelpAvtive2').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive2').index();
            jumpPage1(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage2>a', function () {
            var thisIndex = $(this).index();
            jumpPage2(thisIndex)
        });
        // 跳转页面
        function jumpPage2(thisIndex) {
            if ($('.thisPage2>a').eq(thisIndex).hasClass('pagehelpAvtive2')) return;
            // if ( allIndex ===  allPage[allPage.length-2]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage2>a').removeClass('pagehelpAvtive2');
            $('.thisPage2>a').eq(thisIndex).addClass('pagehelpAvtive2');
            var allIndex = Number($('.pagehelpAvtive2').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage2').children().eq($('.thisPage2').children().length - 1).remove();
                $('.thisPage2 a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage2').children().eq(0).remove();
                $('.thisPage2').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump2() {
            var jumpNum = Number($('.jumpPageNum2').val());
            var allIndex = Number($('.pagehelpAvtive2').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage2').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage2').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage2(j);
                }
            }
        }
    })
}
// 第四个分页
function pageHelp3(options) {
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper3"></div>')




        if (options.prev) {
            $('.pageHelper3').append('<a href="javascript:;" class="prev3">上一页</a>');
        }
        $('.pageHelper3').append('<div class="thisPage3" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage3').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage3').children().eq(0).addClass('pagehelpAvtive3');
        if (options.next) {
            $('.pageHelper3').append('<a  href="javascript:;" class="next3">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper3').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper3').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum3"/> 页</span>');
            $('.pageHelper3').append('<a  href="javascript:;" class="jumpPage3" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum3').bind('keyup', function (event) {
            if (event.keyCode == "13") {
                //回车执行查询
                handJump3();
            }
        });
        $(document).on('click', '.jumpPage3', handJump3);
        // 首页 
        $(document).on('click', '.firstPage3', function () {
            var allIndex = Number($('.pagehelpAvtive3').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage3').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage3').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage3(0);
        });
        // 尾页
        $(document).on('click', '.lastPage3', function () {
            var allIndex = Number($('.pagehelpAvtive3').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage3').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage3').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage3(4);
        });
        // 上一页
        $(document).on('click', '.prev3', function () {
            var allIndex = Number($('.pagehelpAvtive3').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive3').index();
            jumpPage3(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next3', function () {
            var allIndex = Number($('.pagehelpAvtive3').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive3').index();
            jumpPage1(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage3>a', function () {
            var thisIndex = $(this).index();
            jumpPage3(thisIndex)
        });
        // 跳转页面
        function jumpPage3(thisIndex) {
            if ($('.thisPage3>a').eq(thisIndex).hasClass('pagehelpAvtive3')) return;
            // if ( allIndex ===  allPage[allPage.length-3]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage3>a').removeClass('pagehelpAvtive3');
            $('.thisPage3>a').eq(thisIndex).addClass('pagehelpAvtive3');
            var allIndex = Number($('.pagehelpAvtive3').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage3').children().eq($('.thisPage3').children().length - 1).remove();
                $('.thisPage3 a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage3').children().eq(0).remove();
                $('.thisPage3').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump3() {
            var jumpNum = Number($('.jumpPageNum3').val());
            var allIndex = Number($('.pagehelpAvtive3').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage3').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage3').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage3(j);
                }
            }
        }
    })
}
// 第五个分页
function pageHelp4(options) {
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper4"></div>')




        if (options.prev) {
            $('.pageHelper4').append('<a href="javascript:;" class="prev4">上一页</a>');
        }
        $('.pageHelper4').append('<div class="thisPage4" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage4').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage4').children().eq(0).addClass('pagehelpAvtive4');
        if (options.next) {
            $('.pageHelper4').append('<a  href="javascript:;" class="next4">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper4').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper4').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum4"/> 页</span>');
            $('.pageHelper4').append('<a  href="javascript:;" class="jumpPage4" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum4').bind('keyup', function (event) {
            if (event.keyCode == "14") {
                //回车执行查询
                handJump4();
            }
        });
        $(document).on('click', '.jumpPage4', handJump4);
        // 首页 
        $(document).on('click', '.firstPage4', function () {
            var allIndex = Number($('.pagehelpAvtive4').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage4').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage4').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage4(0);
        });
        // 尾页
        $(document).on('click', '.lastPage4', function () {
            var allIndex = Number($('.pagehelpAvtive4').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage4').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage4').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage4(4);
        });
        // 上一页
        $(document).on('click', '.prev4', function () {
            var allIndex = Number($('.pagehelpAvtive4').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive4').index();
            jumpPage4(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next4', function () {
            var allIndex = Number($('.pagehelpAvtive4').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive4').index();
            jumpPage1(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage4>a', function () {
            var thisIndex = $(this).index();
            jumpPage4(thisIndex)
        });
        // 跳转页面
        function jumpPage4(thisIndex) {
            if ($('.thisPage4>a').eq(thisIndex).hasClass('pagehelpAvtive4')) return;
            // if ( allIndex ===  allPage[allPage.length-4]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage4>a').removeClass('pagehelpAvtive4');
            $('.thisPage4>a').eq(thisIndex).addClass('pagehelpAvtive4');
            var allIndex = Number($('.pagehelpAvtive4').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage4').children().eq($('.thisPage4').children().length - 1).remove();
                $('.thisPage4 a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage4').children().eq(0).remove();
                $('.thisPage4').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump4() {
            var jumpNum = Number($('.jumpPageNum4').val());
            var allIndex = Number($('.pagehelpAvtive4').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage4').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage4').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage4(j);
                }
            }
        }
    })
}
// 第六个分页
function pageHelp5(options) {
    layui.use(['layer', 'carousel', 'laypage'], function () {
        var $ = layui.$
        var limits = Math.ceil(options.count / options.limit);
        var allPage = [];
        var thisPage = [];
        for (var i = 1; i <= limits; i++) {
            allPage.push(i);
            if (i < 6) {
                thisPage.push(i);
            }
        };
        $(options.ele).children().remove();
        $(options.ele).append('<div class="layui-box layui-laypage layui-laypage-default pageHelper5"></div>')




        if (options.prev) {
            $('.pageHelper5').append('<a href="javascript:;" class="prev5">上一页</a>');
        }
        $('.pageHelper5').append('<div class="thisPage5" style="display:inline;"></div>');
        for (var j = 0; j < thisPage.length; j++) {
            $('.thisPage5').append('<a href="javascript:;">' + thisPage[j] + '</a>');
        }
        $('.thisPage5').children().eq(0).addClass('pagehelpAvtive5');
        if (options.next) {
            $('.pageHelper5').append('<a  href="javascript:;" class="next5">下一页</a>');
        }
        if (options.allPage) {
            $('.pageHelper5').append('<span class="layui-laypage-count">共' + limits + '页</span>');
        }
        if (options.jump) {
            $('.pageHelper5').append('<span class="layui-laypage-skip">去 <input class="jumpPageNum5"/> 页</span>');
            $('.pageHelper5').append('<a  href="javascript:;" class="jumpPage5" >GO</a>');
        }
        // 手动跳转页面
        $('.jumpPageNum5').bind('keyup', function (event) {
            if (event.keyCode == "14") {
                //回车执行查询
                handJump5();
            }
        });
        $(document).on('click', '.jumpPage5', handJump5);
        // 首页 
        $(document).on('click', '.firstPage5', function () {
            var allIndex = Number($('.pagehelpAvtive5').html());
            if (allIndex === allPage[0]) return;
            thisPage = allPage.slice(0, 5);
            $('.thisPage5').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage5').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage5(0);
        });
        // 尾页
        $(document).on('click', '.lastPage5', function () {
            var allIndex = Number($('.pagehelpAvtive5').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            $('.thisPage5').children().remove();
            thisPage = allPage.slice(-5);
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage5').append('<a href="javascript:;">' + thisPage[j] + '</a>');
            }
            jumpPage5(4);
        });
        // 上一页
        $(document).on('click', '.prev5', function () {
            var allIndex = Number($('.pagehelpAvtive5').html());
            if (allIndex === allPage[0]) return;
            var activeindex = $('.pagehelpAvtive5').index();
            jumpPage5(activeindex - 1)
        });
        // 下一页
        $(document).on('click', '.next5', function () {
            var allIndex = Number($('.pagehelpAvtive5').html());
            if (allIndex === allPage[allPage.length - 1]) return;
            var activeindex = $('.pagehelpAvtive5').index();
            jumpPage1(activeindex + 1)
        });
        // 点击页码
        $(document).on('click', '.thisPage5>a', function () {
            var thisIndex = $(this).index();
            jumpPage5(thisIndex)
        });
        // 跳转页面
        function jumpPage5(thisIndex) {
            if ($('.thisPage5>a').eq(thisIndex).hasClass('pagehelpAvtive5')) return;
            // if ( allIndex ===  allPage[allPage.length-5]) return;
            // if ( allIndex ===  allPage[0]) return;
            $('.thisPage5>a').removeClass('pagehelpAvtive5');
            $('.thisPage5>a').eq(thisIndex).addClass('pagehelpAvtive5');
            var allIndex = Number($('.pagehelpAvtive5').html());
            options.fn(allIndex)
            if (thisIndex === 0 && allIndex !== allPage[0]) {
                $('.thisPage5').children().eq($('.thisPage5').children().length - 1).remove();
                $('.thisPage5 a').eq(0).before('<a href="javascript:;">' + allPage[allIndex - 2] + '</a>');
            };
            if (thisIndex === 4 && allIndex !== allPage[allPage.length - 1]) {
                $('.thisPage5').children().eq(0).remove();
                $('.thisPage5').append('<a href="javascript:;">' + allPage[allIndex] + '</a>');
            };
        }
        // 手动填写跳转页面
        function handJump5() {
            var jumpNum = Number($('.jumpPageNum5').val());
            var allIndex = Number($('.pagehelpAvtive5').html());
            if (!jumpNum || jumpNum === allIndex || jumpNum < allPage[0] || jumpNum > allPage[allPage.length - 1]) return;
            // 前不够
            if (jumpNum - 3 < 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(0).splice(0, 5);
                } else {
                    // 后不够
                    thisPage = allPage.slice(5 - (jumpNum - allPage.length)).splice(0, 5)
                }
            }
            // 前够
            if (jumpNum - 3 >= 0) {
                // 后够
                if ((allPage.length - jumpNum) > 2) {
                    thisPage = allPage.slice(jumpNum - 3).splice(0, 5)
                } else {
                    // 后不够
                    thisPage = allPage.slice(allPage.length - 5)
                }
            }
            $('.thisPage5').children().remove();
            for (var j = 0; j < thisPage.length; j++) {
                $('.thisPage5').append('<a href="javascript:;">' + thisPage[j] + '</a>');
                if (thisPage[j] == jumpNum) {
                    jumpPage5(j);
                }
            }
        }
    })
}
